import {GenField} from "@/pages/system/tool/gen/type";
import {ProColumns} from "@ant-design/pro-table";
import {Checkbox, Tag} from "antd";

// @ts-ignore
const columns: ProColumns<GenField>[] = (javaFieldList: any) => [
  {
    title: "数据库字段名",
    dataIndex: "tableField",
    editable: false,
    align: "center",
    fixed: "left",
    width: "200px",
  },
  {
    title: "数据库类型",
    dataIndex: "tableFieldType",
    editable: false,
    align: "center",
    width: "200px",

  },
  {
    title: "java字段名",
    dataIndex: "name",
    align: "center",
    width: "200px",
    formItemProps: {
      rules: [
        {
          required: true,
          message: "此项为必填项"
        }
      ],
    }
  },
  {
    title: "java类型",
    dataIndex: "fieldType",
    width: "200px",
    align: "center",
    valueEnum: javaFieldList,
    valueType: "select",
    formItemProps: {
      rules: [
        {
          required: true,
          message: "此项为必填项"
        }
      ],
    }
  },
  {
    title: "字段描述",
    align: "center",
    width: "200px",
    dataIndex: "comment",
    formItemProps: {
      rules: [
        {
          required: true,
          message: "此项为必填项"
        }
      ],
    }
  },
  {
    title: "是时间",
    align: "center",
    width: "200px",
    dataIndex: "isTime",
    // @ts-ignore
    render: (dom, entity, index, action, schema) => {
      if (entity.isTime) {
        return (<Tag color="success">是</Tag>)
      }
      return (<Tag color="warning">否</Tag>)
    },
    editable: false
  },
  {
    title: "为新增字段",
    align: "center",
    width: "200px",
    dataIndex: "add",
    // @ts-ignore
    render: (dom, entity, index, action, schema) => {
      return (<Checkbox defaultChecked={entity.add} onClick={() => entity.add = !entity.add}></Checkbox>)
    },
    editable: false
  },
  {
    title: "为导入字段",
    align: "center",
    width: "200px",
    dataIndex: "import",
    // @ts-ignore
    render: (dom, entity, index, action, schema) => {
      return (<Checkbox defaultChecked={entity.import} onClick={() => entity.import = !entity.import}></Checkbox>)
    },
    editable: false
  },
  {
    title: "导出字段",
    align: "center",
    width: "200px",
    dataIndex: "export",
    // @ts-ignore
    render: (dom, entity, index, action, schema) => {
      return (<Checkbox
        defaultChecked={entity.export}
        onClick={() => entity.export = !entity.export}/>)
    },
    editable: false
  },
  {
    title: "为表格字段",
    align: "center",
    width: "200px",
    dataIndex: "res",
    // @ts-ignore
    render: (dom, entity, index, action, schema) => {
      return (<Checkbox defaultChecked={entity.res} onClick={() => entity.res = !entity.res}></Checkbox>)
    },
    editable: false
  },
  {
    title: "为详情字段",
    align: "center",
    width: "200px",
    dataIndex: "detail",
    // @ts-ignore
    render: (dom, entity, index, action, schema) => {
      return (<Checkbox defaultChecked={entity.detail} onClick={() => entity.detail = !entity.detail}></Checkbox>)
    },
    editable: false
  },
  {
    title: "为搜索字段",
    width: "200px",
    align: "center",
    dataIndex: "search",
    // @ts-ignore
    render: (dom, entity, index, action, schema) => {
      return (<Checkbox defaultChecked={entity.search} onClick={() => entity.search = !entity.search}></Checkbox>)
    },
    editable: false
  },
]

export default columns;
